/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.tarifador.util;

import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 * Hibernate Utility class with a convenient method to get Session Factory
 * object.
 *
 * @author charles
 */
public class HibernateUtil {
	private static SessionFactory sessionFactory = buildSessionFactory();
	private static AnnotationConfiguration cfg;

	private static SessionFactory buildSessionFactory() throws HibernateException{
	cfg = new AnnotationConfiguration().configure();
	return cfg.buildSessionFactory();
	}

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }
}
